import Vue from 'vue'
import App from './App'
import router from './router'
import elementUI from './plugins/element-ui'
import axios from 'axios'
import BasePage from './components/BasePage'
import Cookies from 'js-cookie'

import TreeSelect from './components/TreeSelect'
import tree from './components/TreeSelect2'

Vue.config.productionTip = false

axios.defaults.baseURL = 'http://127.0.0.1:8000/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = Cookies.get('Authorization')
  return config
})
Vue.prototype.$http = axios

Vue.component('BasePage', BasePage)
Vue.component('tree-select', TreeSelect)
Vue.component('tree', tree) 

// 时间过滤器
Vue.filter('dateFormat', function dateFormat(originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

new Vue({
  router,
  elementUI,
  render: h => h(App)
}).$mount('#app')
